#include <zneo.h>

#include "LEDs.h"
#include "light_sensor.h"
#include "system.h"

int counter = 0;

void init_buttons(void) {
	// Set Port D Data Direction on pin 3 to OUT (PD3 corresponds to the first button SW1)
	PDDD |= 0x08;

	// Set Port F Data Direction on pins 6 and 7 to OUT (PF6 and PF7 correspond to the second and third switches, SW2 and SW3)
	PFDD |= 0xC0;

}

void check_buttons(void) {
	counter++;

	if (counter >= 3) {
		set_led_text("READ");
	}

	// Associate the buttons with tunes 1, 2, and 3.
	if ((~PDIN & 0x08) == 0x08) { // Button 1
		counter = 0;
		increase_red_capacitance();
	} else if ((~PFIN & 0x40) == 0x40) { // Button 2
		counter = 0;
		increase_green_capacitance();
	} else if ((~PFIN & 0x80) == 0x80) { // Button 3
		counter = 0;
		increase_blue_capacitance();
	}
	wait(150);
}